<?php

/**
 * categoria actions.
 *
 * @package    oacademy
 * @subpackage categoria
 * @author     Otto Giron
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class categoryActions extends sfActions
{
	/**
	 * Executes index action
	 *
	 * @param sfRequest $request A request object
	 */
	public function executeIndex(sfWebRequest $request)
	{
		$this->forward('default', 'module');
	}
	
    public function executeListCourses(sfWebRequest $request)
	{
	   	$category=$this->getRoute()->getObject();
	    $latestCourseQuery=Doctrine_Core::getTable('Course')->getLatestCoursesQuery();
	    $currentPage=$request->getParameter('page', 1);
	    $maxCoursesPerPage=sfConfig::get("app_max_courses_on_homepage");
	    $courseTableAlias=$latestCourseQuery->getRootAlias();
	    $latestCourseQuery->addWhere("$courseTableAlias.category_id=?",$category->getId());
	 	$this->pager=new sfDoctrinePager('Course',
	            $maxCoursesPerPage);
	    $this->pager->setQuery($latestCourseQuery);	   
	    $this->pager->setPage($currentPage);
	    $this->pager->init();    	
	}
	
	
	

}
